package com.qzsoft.zhjd.asphalt.modules.consumptionstatistics.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.qzsoft.jeemis.common.utils.Result;
import com.qzsoft.zhjd.asphalt.modules.consumptionstatistics.dto.ActCountDto;
import com.qzsoft.zhjd.asphalt.modules.consumptionstatistics.dto.ConsumptionStatisticsTableDto;
import com.qzsoft.zhjd.asphalt.modules.consumptionstatistics.dto.TheoCountDto;
import com.qzsoft.zhjd.asphalt.modules.consumptionstatistics.service.ConsumptionStatisticsService;
import com.qzsoft.zhjd.common.utils.ResultUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * 材料消耗偏差统计
 */
@RestController
@RequestMapping("/api/consumptionStatistics")
public class ConsumptionStatisticsController {

    @Autowired
    private ConsumptionStatisticsService consumptionStatisticsService;

    /**
     * 数据分页
     *
     * @param params
     * @return
     */
    @RequestMapping("/page")
    public Result<IPage<ConsumptionStatisticsTableDto>> page(@RequestParam Map<String, Object> params) {
        IPage<ConsumptionStatisticsTableDto> data = consumptionStatisticsService.page(params);
        return ResultUtils.ok(data);
    }

    /**
     * 获取实际材料消耗
     *
     * @param params
     * @return
     */
    @RequestMapping("/actCount")
    public Result<ActCountDto> actCount(@RequestParam Map<String, Object> params) {
        return ResultUtils.ok(consumptionStatisticsService.actCount(params));
    }

    /**
     * 理论材料消耗
     *
     * @param params
     * @return
     */
    @RequestMapping("/theoCount")
    public Result<TheoCountDto> theoCount(@RequestParam Map<String, Object> params) {
        return ResultUtils.ok(consumptionStatisticsService.theoCount(params));
    }
}
